package com.cskaoyan.jdbc.dbutils;

import com.cskaoyan.jdbc.dbutils.bean.Stu;
import org.apache.commons.dbutils.ResultSetHandler;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Map;

/**
 * 创建日期: 2022/05/16 11:04
 *
 * @author ciggar
 */
public class MyResultSetHandler implements ResultSetHandler {
    @Override
    public Object handle(ResultSet resultSet) throws SQLException {
        Stu stu = new Stu();

        if (resultSet.next()) {

            int id = resultSet.getInt("id");
            String name = resultSet.getString("name");
            int age = resultSet.getInt("age");
            String clazz = resultSet.getString("class");

            stu.setId(id);
            stu.setName(name);
            stu.setAge(age);
            stu.setClazz(clazz);

        }

        return stu;
    }
}
